﻿using IceZero.Business;
using IceZero.Web.Helpers;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IceZero.Web.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class TableRecordIncrementController : ControllerBase
    {
        private TableRecordIncrementBusiness _tableRecordIncrementBusiness;
        public TableRecordIncrementController(TableRecordIncrementBusiness tableRecordIncrementBusiness)
        {
            _tableRecordIncrementBusiness = tableRecordIncrementBusiness;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="columnName"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetTableFieldNo(string tableName, string columnName)
        {
            return ActionHelper.ExecAction(this, controller =>
            {
                return _tableRecordIncrementBusiness.GetTableFieldNo(tableName, columnName);
            });
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="columnName"></param>
        /// <param name="orderNumber"></param>
        /// <param name="stepNumber"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult AddTableFieldNo(string tableName, string columnName, int orderNumber = 0, int stepNumber = 1)
        {
            return ActionHelper.ExecAction(this, controller =>
            {
                _tableRecordIncrementBusiness.AddTableFieldNo(tableName, columnName, orderNumber, stepNumber);
            });
        }
    }
}
